package ru.ng.sample.ui.validators;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;
import ru.ng.sample.core.notes.Note;

/**
 * User: ngorosh
 * Date: 28.05.11
 * Time: 21:29
 */
public class NoteValidator implements Validator
{
    @Override
    public boolean supports( Class<?> clazz )
    {
        return Note.class.equals( clazz );
    }

    @Override
    public void validate( Object target, Errors errors )
    {
        ValidationUtils.rejectIfEmpty( errors, "name", "required");
    }
}
